package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysWind;
import com.ruoyi.system.service.ISysWindService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 风场Controller
 *
 * @author ruoyi
 * @date 2023-11-27
 */
@RestController
@RequestMapping("/system/wind")
public class SysWindController extends BaseController
{
    @Autowired
    private ISysWindService sysWindService;

    /**
     * 查询风场列表
     */
    @PreAuthorize("@ss.hasPermi('system:wind:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysWind sysWind)
    {
        startPage();
        List<SysWind> list = sysWindService.selectSysWindList(sysWind);
        return getDataTable(list);
    }

    /**
     * 导出风场列表
     */
    @PreAuthorize("@ss.hasPermi('system:wind:export')")
    @Log(title = "风场", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysWind sysWind)
    {
        List<SysWind> list = sysWindService.selectSysWindList(sysWind);
        ExcelUtil<SysWind> util = new ExcelUtil<SysWind>(SysWind.class);
        util.exportExcel(response, list, "风场数据");
    }

    /**
     * 获取风场详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:wind:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysWindService.selectSysWindById(id));
    }

    /**
     * 新增风场
     */
    @PreAuthorize("@ss.hasPermi('system:wind:add')")
    @Log(title = "风场", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWind sysWind)
    {
        return toAjax(sysWindService.insertSysWind(sysWind));
    }

    /**
     * 修改风场
     */
    @PreAuthorize("@ss.hasPermi('system:wind:edit')")
    @Log(title = "风场", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWind sysWind)
    {
        return toAjax(sysWindService.updateSysWind(sysWind));
    }

    /**
     * 删除风场
     */
    @PreAuthorize("@ss.hasPermi('system:wind:remove')")
    @Log(title = "风场", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysWindService.deleteSysWindByIds(ids));
    }
}
